package com.canaan.business.controller.pc.barcode;

import com.canaan.business.domain.barcode.UploadCircubill;
import com.canaan.business.service.barcode.IUploadCircubillService;
import com.canaan.common.annotation.Log;
import com.canaan.common.core.controller.BaseController;
import com.canaan.common.core.domain.AjaxResult;
import com.canaan.common.core.page.TableDataInfo;
import com.canaan.common.enums.BusinessType;
import com.canaan.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 监管码Controller
 *
 * @author yangjie
 * @date 2025-01-15
 */
@Api(tags = "监管码")
@RestController
@RequestMapping("/barcode/uploadcircubill")
public class UploadCircubillController extends BaseController {
    @Resource
    private IUploadCircubillService uploadCircubillService;

    /**
     * 查询监管码列表
     */
    @ApiOperation(value = "查询监管码列表")
    @PreAuthorize("@ss.hasPermi('barcode:uploadcircubill:list')")
    @GetMapping("/list")
    public TableDataInfo list(UploadCircubill uploadCircubill) {
        startPage();
        List<UploadCircubill> list = uploadCircubillService.selectUploadCircubillList(uploadCircubill);
        return getDataTable(list);
    }

    /**
     * 导出监管码列表
     */
    @ApiOperation(value = "导出监管码列表")
    @PreAuthorize("@ss.hasPermi('barcode:uploadcircubill:export')")
    @Log(title = "监管码", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UploadCircubill uploadCircubill) {
        List<UploadCircubill> list = uploadCircubillService.selectUploadCircubillList(uploadCircubill);
        ExcelUtil<UploadCircubill> util = new ExcelUtil<UploadCircubill>(UploadCircubill.class);
        util.exportExcel(response, list, "监管码数据");
    }

    /**
     * 获取监管码详细信息
     */
    @ApiOperation(value = "获取监管码详细信息")
    @PreAuthorize("@ss.hasPermi('barcode:uploadcircubill:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(uploadCircubillService.selectUploadCircubillById(id));
    }

    /**
     * 新增监管码
     */
    @ApiOperation(value = "新增监管码")
    @PreAuthorize("@ss.hasPermi('barcode:uploadcircubill:add')")
    @Log(title = "监管码", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UploadCircubill uploadCircubill) {
        return toAjax(uploadCircubillService.insertUploadCircubill(uploadCircubill));
    }

    /**
     * 修改监管码
     */
    @ApiOperation(value = "修改监管码")
    @PreAuthorize("@ss.hasPermi('barcode:uploadcircubill:edit')")
    @Log(title = "监管码", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UploadCircubill uploadCircubill) {
        return toAjax(uploadCircubillService.updateUploadCircubill(uploadCircubill));
    }

    /**
     * 删除监管码
     */
    @ApiOperation(value = "删除监管码")
    @PreAuthorize("@ss.hasPermi('barcode:uploadcircubill:remove')")
    @Log(title = "监管码", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(uploadCircubillService.deleteUploadCircubillByIds(ids));
    }
}
